package com.sds.shop.dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;

import com.sds.fw.dao.AbDao;
import com.sds.shop.vo.MyOrderVO;
import com.sds.shop.vo.OrderVO;

public class MyOrderDAO extends AbDao {
	private static MyOrderDAO dao = new MyOrderDAO();

	public static MyOrderDAO getInstance() {
		return dao;
	}
	
	public ArrayList <MyOrderVO> getMyOrder (String mem_id)
	{
		/*
 String ord_no;
String prd_no;
	String ord_dtm;
	private String prd_nm;
	private String ord_amt;
		 * 
		 * */
		Connection conn = null;
		Statement stmt = null;
		ResultSet rs = null;
		ArrayList <MyOrderVO> arr_or = new ArrayList<MyOrderVO>();
		try {
			conn=connect();
			String query="select o.ord_no, o.ord_dtm, p.prd_nm, o.ord_amt, p.prd_no, o.ord_stat_cd, py.payment_opt_cd, py.pay_amt " +
					"from tb_order o, tb_order_product op, tb_product p, tb_payment py " +
					"where o.ord_no=op.ord_no and op.prd_no=p.prd_no and py.ord_no = o.ord_no " +
					"order by o.ord_dtm desc";
			stmt=conn.createStatement();
			rs=stmt.executeQuery(query);
			while(rs.next())
			{
				MyOrderVO vo = new MyOrderVO();
				vo.setOrd_no(rs.getString(1));
				vo.setOrd_dtm(rs.getString(2));
				vo.setPrd_nm(rs.getString(3));
				vo.setOrd_amt(rs.getString(4));
				vo.setPrd_no(rs.getString(5));
				vo.setOrd_state(rs.getString(6));
				vo.setPay_opt_code(rs.getString(7));
				vo.setPay_amt(rs.getString(8));
				
				arr_or.add(vo);
			}
			return arr_or;
		} catch (Exception ex) {
			System.out.println("getOrder exception : " + ex);
		}
		return arr_or;
	}
}
